<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
 <META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.7">
 <TITLE>SDCC Compiler User Guide</TITLE>
 <LINK HREF="SDCCUdoc-1.html" REL=next>


</HEAD>
<BODY>
<A HREF="SDCCUdoc-1.html">Next</A>
Previous
Contents
<HR>
<H1>SDCC Compiler User Guide</H1>

<H2>Sandeep Dutta (sandeep.dutta@usa.net)</H2>
<P>
<H2><A NAME="toc1">1.</A> <A HREF="SDCCUdoc-1.html">Introduction</A></H2>

<P>
<H2><A NAME="toc2">2.</A> <A HREF="SDCCUdoc-2.html">Installation </A></H2>

<UL>
<LI><A HREF="SDCCUdoc-2.html#ss2.1">2.1 Components of SDCC</A>
<LI><A HREF="SDCCUdoc-2.html#ss2.2">2.2 Installation for Version &lt;= 2.1.7</A>
<LI><A HREF="SDCCUdoc-2.html#ss2.3">2.3 Installation for Version &gt;= 2.1.8a</A>
<P>
<H2><A NAME="toc3">3.</A> <A HREF="SDCCUdoc-3.html">Compiling.</A></H2>

<UL>
<LI><A HREF="SDCCUdoc-3.html#ss3.1">3.1 Single Source file projects.</A>
<LI><A HREF="SDCCUdoc-3.html#ss3.2">3.2 Projects with multiple source files.</A>
<LI><A HREF="SDCCUdoc-3.html#ss3.3">3.3 Projects with additional libraries.</A>
<P>
<H2><A NAME="toc4">4.</A> <A HREF="SDCCUdoc-4.html">Command Line options</A></H2>

<P>
<H2><A NAME="toc5">5.</A> <A HREF="SDCCUdoc-5.html">Language Extensions</A></H2>

<UL>
<LI><A HREF="SDCCUdoc-5.html#ss5.1">5.1 Storage Classes.</A>
<P>
<H2><A NAME="toc6">6.</A> <A HREF="SDCCUdoc-6.html">Optimizations</A></H2>

<UL>
<LI><A HREF="SDCCUdoc-6.html#ss6.1">6.1 Sub-expression elimination</A>
<LI><A HREF="SDCCUdoc-6.html#ss6.2">6.2 Dead-Code elimination.</A>
<LI><A HREF="SDCCUdoc-6.html#ss6.3">6.3 Copy-Propagation:</A>
<LI><A HREF="SDCCUdoc-6.html#ss6.4">6.4 Loop optimizations</A>
<LI><A HREF="SDCCUdoc-6.html#ss6.5">6.5 Algebraic simplifications:</A>
<LI><A HREF="SDCCUdoc-6.html#ss6.6">6.6 'switch' statements.</A>
<LI><A HREF="SDCCUdoc-6.html#ss6.7">6.7 bit-shifting operations.</A>
<LI><A HREF="SDCCUdoc-6.html#ss6.8">6.8 Highest Order Bit.</A>
<LI><A HREF="SDCCUdoc-6.html#ss6.9">6.9 Peep-hole optimizer.</A>
<P>
<H2><A NAME="toc7">7.</A> <A HREF="SDCCUdoc-7.html">Pointers</A></H2>

<P>
<H2><A NAME="toc8">8.</A> <A HREF="SDCCUdoc-8.html">Parameters &amp; Local Variables</A></H2>

<UL>
<LI><A HREF="SDCCUdoc-8.html#ss8.1">8.1 Overlaying</A>
<P>
<H2><A NAME="toc9">9.</A> <A HREF="SDCCUdoc-9.html">critical Functions.</A></H2>

<P>
<H2><A NAME="toc10">10.</A> <A HREF="SDCCUdoc-10.html">Absolute addressing.</A></H2>

<P>
<H2><A NAME="toc11">11.</A> <A HREF="SDCCUdoc-11.html">Interrupt Service Routines</A></H2>

<P>
<H2><A NAME="toc12">12.</A> <A HREF="SDCCUdoc-12.html">Startup Code</A></H2>

<P>
<H2><A NAME="toc13">13.</A> <A HREF="SDCCUdoc-13.html">Inline assembler code.</A></H2>

<P>
<H2><A NAME="toc14">14.</A> <A HREF="SDCCUdoc-14.html">int (16 bit) and long (32 bit ) support.</A></H2>

<P>
<H2><A NAME="toc15">15.</A> <A HREF="SDCCUdoc-15.html">Floating point support</A></H2>

<P>
<H2><A NAME="toc16">16.</A> <A HREF="SDCCUdoc-16.html">Memory Models</A></H2>

<P>
<H2><A NAME="toc17">17.</A> <A HREF="SDCCUdoc-17.html">Flat 24 bit addressing model.</A></H2>

<P>
<H2><A NAME="toc18">18.</A> <A HREF="SDCCUdoc-18.html">Defines created by the compiler.</A></H2>

<P>
<H2><A NAME="toc19">19.</A> <A HREF="SDCCUdoc-19.html">Pragmas</A></H2>

<P>
<H2><A NAME="toc20">20.</A> <A HREF="SDCCUdoc-20.html">Library routines.</A></H2>

<P>
<PRE>
printf_small("my str %s, my int %d\n",(char _generic *)mystr,myint);
  
</PRE>

<P>
<UL>
<LI><B>stdarg.h </B>- contains definition for the following macros to be used for
variable parameter list, note that a function can have a variable parameter
list if and only if it is 'reentrant'
<P>va_list, va_start, va_arg, va_end.
</LI>
<LI><B>setjmp.h </B>- contains defintion for ANSI<B> setjmp </B>&amp; <B>longjmp</B> routines. Note
in this case setjmp &amp; longjmp can be used between functions executing within
the same register bank, if long jmp is executed from a function that is using
a different register bank from the function issuing the setjmp function, the
results may be unpredictable. The jump buffer requires 3 bytes of data (the
stack pointer &amp; a 16 byte return address), and can be placed in any address
space.</LI>
<LI><B>stdlib.h</B> - contains the following functions.
<P>atoi, atol.
</LI>
<LI><B>string.h </B>- contains the following functions.
<P>strcpy, strncpy, strcat, strncat, strcmp, strncmp, strchr, strrchr, strspn,
strcspn, strpbrk, strstr, strlen, strtok, memcpy, memcmp, memset.
</LI>
<LI><B>ctype.h</B> - contains the following routines.
<P>iscntrl, isdigit, isgraph, islower, isupper, isprint, ispunct, isspace,
isxdigit, isalnum, isalpha.
</LI>
<LI><B>malloc.h</B> - The malloc routines are developed by Dmitry S. Obukhov (dso@usa.net).
These routines will allocate memory from the external ram. Here is a description
on how to use them (as described by the author).
<PRE>
//Example: 
     //     #define DYNAMIC_MEMORY_SIZE 0x2000 
     //    
 ..... 
     //     unsigned char xdata dynamic_memory_pool[DYNAMIC_MEMORY_SIZE];
 
     //     unsigned char xdata * current_buffer; 
     //     ..... 
    
 //     void main(void) 
     //     { 
     //         ... 
     //        
 init_dynamic_memory(dynamic_memory_pool,DYNAMIC_MEMORY_SIZE); 
     //        
 //Now it's possible to use malloc. 
     //         ... 
     //         current_buffer
 = malloc(0x100); 
     //
  
</PRE>
</LI>
<LI><B>serial.h</B> - Serial IO routines are also developed by Dmitry S. Obukhov (dso@usa.net).
These routines are interrupt driven with a 256 byte circular buffer, they also
expect external ram to be present. Please see documentation in file SDCCDIR/sdcc51lib/serial.c
. Note the header file "serial.h" MUST be included in the file containing the
'main' function.</LI>
<LI><B>ser.h </B>- Alternate serial routine provided by Wolfgang Esslinger &lt;wolfgang@WiredMinds.com&gt;
these routines are more compact and faster. Please see documentation in file
SDCCDIR/sdcc51lib/ser.c</LI>
<LI><B>ser_ir.h </B>- Another alternate set of serial routines provided by Josef Wolf
&lt;jw@raven.inka.de&gt; , these routines do not use the external ram.</LI>
<LI><B>reg51.h</B> - contains register definitions for a standard 8051</LI>
<LI><B>reg552.h </B>- contains register definitions for 80C552.</LI>
<LI><B>float.h</B> - contains min, max and other floating point related stuff.</LI>
</UL>
<P>All library routines are compiled as --model-small , they are all non-reentrant,
if you plan to use the large model or want to make these routines reentrant,
then they will have to be recompiled with the appropriate compiler option.
<P>Have not had time to do the more involved routines like printf, will get
to them shortly.
<P>
<H2><A NAME="toc21">21.</A> <A HREF="SDCCUdoc-21.html">Interfacing with assembly routines.</A></H2>

<UL>
<LI><A HREF="SDCCUdoc-21.html#ss21.1">21.1 Global registers used for parameter passing.</A>
<LI><A HREF="SDCCUdoc-21.html#ss21.2">21.2 With --noregparms option.</A>
<P>
<H2><A NAME="toc22">22.</A> <A HREF="SDCCUdoc-22.html">External Stack.</A></H2>

<P>
<H2><A NAME="toc23">23.</A> <A HREF="SDCCUdoc-23.html">ANSI-Compliance.</A></H2>

<P>
<H2><A NAME="toc24">24.</A> <A HREF="SDCCUdoc-24.html">Cyclomatic Complexity</A></H2>

<P>
<H2><A NAME="toc25">25.</A> <A HREF="SDCCUdoc-25.html">TIPS</A></H2>

<P>
<H2><A NAME="toc26">26.</A> <A HREF="SDCCUdoc-26.html">Retargetting for other MCUs.</A></H2>

<P>
<H2><A NAME="toc27">27.</A> <A HREF="SDCCUdoc-27.html">Reporting Bugs</A></H2>

<P>
<H2><A NAME="toc28">28.</A> <A HREF="SDCCUdoc-28.html">SDCDB - Source level debugger.</A></H2>

<UL>
<LI><A HREF="SDCCUdoc-28.html#ss28.1">28.1 Compiling for debugging.</A>
<LI><A HREF="SDCCUdoc-28.html#ss28.2">28.2 How the debugger works.</A>
<LI><A HREF="SDCCUdoc-28.html#ss28.3">28.3 Starting the debugger.</A>
<LI><A HREF="SDCCUdoc-28.html#ss28.4">28.4 Command line options.</A>
<LI><A HREF="SDCCUdoc-28.html#ss28.5">28.5 Debugger Commands.</A>
<LI><A HREF="SDCCUdoc-28.html#ss28.6">28.6 Interfacing with XEmacs.</A>
<P>
<H2><A NAME="toc29">29.</A> <A HREF="SDCCUdoc-29.html">Conclusion</A></H2>

<P>
<H2><A NAME="toc30">30.</A> <A HREF="SDCCUdoc-30.html">Acknowledgments</A></H2>

<P>
<H2><A NAME="toc31">31.</A> <A HREF="SDCCUdoc-31.html">Appendix A: The Z80 and gbz80 port</A></H2>

<HR>
<A HREF="SDCCUdoc-1.html">Next</A>
Previous
Contents
</BODY>
</HTML>
